package com.example.walled_houses.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.walled_houses.entity.House;
import com.example.walled_houses.mapper.HouseMapper;
import com.example.walled_houses.service.HouseService;
import com.example.walled_houses.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chengtaoxie
 * @since 2023-10-24
 */
@CrossOrigin
@Api(tags = "围屋信息接口")
@RestController
@RequestMapping("/house")
public class HouseController {

    @Resource
    private HouseService houseService;

    @ApiOperation("分页查询围屋信息")
    @GetMapping("/getHouse/{currentPage}")
    public Result getHouse(@PathVariable Integer currentPage){
        return houseService.getHouse(currentPage);
    }


    @ApiOperation("围屋图片上传")
    @PostMapping("/uploadPhoto")
    public Result uploadPhoto(@RequestBody MultipartFile[] files){
        return houseService.uploadPhoto(files);
    }


    @ApiOperation("增加围屋信息")
    @PostMapping("/addHouse")
    public Result addHouse(@RequestBody House house){
        return houseService.addHouse(house);
    }

//    //es实现分页
//    @ApiOperation("分页查询和搜索围屋信息")
//    @GetMapping("/selectList/{currentPage}")
//

}

